package com.ujoku.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.labillusion.core.util.jsonFormat.SimpleDoubleSerializer;

import java.util.List;

/**
 * Created by greg.chen on 14-10-22.
 */
public class Cart {
    private String id;
    private Integer memberId;
    private String visitorId;
    private List<CartItem> cartItemList;
    @JsonSerialize(using = SimpleDoubleSerializer.class)
    private Double total;
    @JsonSerialize(using = SimpleDoubleSerializer.class)
    private Double subTotal;
    @JsonSerialize(using = SimpleDoubleSerializer.class)
    private Double discount;
    private int level;
    @JsonSerialize(using = SimpleDoubleSerializer.class)
    private Double discountPercent;

    private Integer deliveryType;

    private Address shippingAddress;
    private Store store;

    private List<String> messageList;

    public List<String> getMessageList() {
        return messageList;
    }

    public void setMessageList(List<String> messageList) {
        this.messageList = messageList;
    }

    public Address getShippingAddress() {
        return shippingAddress;
    }

    private int ItemCount;

    public Store getStore() {
        return store;
    }

    public void setStore(Store store) {
        this.store = store;
    }

    public int getItemCount() {
        if(cartItemList != null)

            return cartItemList.stream().mapToInt(i->i.getQty()).sum();

        return 0;
    }

    public void setShippingAddress(Address shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    public Integer getDeliveryType() {
        return deliveryType;
    }

    public void setDeliveryType(Integer deliveryType) {
        this.deliveryType = deliveryType;
    }

    @JsonSerialize(using = SimpleDoubleSerializer.class)
    private Double shippingFee;

    public Double getShippingFee() {
        return shippingFee;
    }

    public void setShippingFee(Double shippingFee) {
        this.shippingFee = shippingFee;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public Double getSubTotal() {
        return subTotal;
    }

    public void setSubTotal(Double subTotal) {
        this.subTotal = subTotal;
    }

    public Double getDiscount() {
        return discount;
    }

    public void setDiscount(Double discount) {
        this.discount = discount;
    }

    public Double getDiscountPercent() {
        return discountPercent;
    }

    public void setDiscountPercent(Double discountPercent) {
        this.discountPercent = discountPercent;
    }

    public List<CartItem> getCartItemList() {
        return cartItemList;
    }

    public void setCartItemList(List<CartItem> cartItemList) {
        this.cartItemList = cartItemList;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getMemberId() {
        return memberId;
    }

    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

    public String getVisitorId() {
        return visitorId;
    }

    public void setVisitorId(String visitorId) {
        this.visitorId = visitorId;
    }

    public Double getTotal() {
        return total;
    }

    public void setTotal(Double total) {
        this.total = total;
    }
}
